import {Utils} from "jboot-env";

export default function (http) {
	return {
		queryAll (data){
			return http
				.mock(function () {
				    return Utils.loopGenerate(15, index => {
				        return {
				            id: index + 1,
				            name: '测试角色',
				            code: 'testRole',
				            remark: '这是测试角色',
				            createTime: '2022-09-03 16:18:22',
				        }
				    });
				})
				.postJson('/demo/role/queryAll', data);
		},

		queryByPage (data){
			return http
				.mock(function () {
				    return {"total":2,"list":[{"code":"D2","parentPath":"0,ee5224cb6bd64be3a287b11cd70b2fe0,","delFlag":"0","updateBy":"274332f8f1fe419096a2a5623dbfefb8","sysAttachments":[],"id":"ee5224cb6bd64be3a287b11cd70b2fe0","shopId":"ef4ccd55cfec4d93a607c04cab023794","state":"1","updateTime":"2022-11-19 23:46:21","sort":999,"createTime_str":"2022-11-19 23:46:21","parentId":"0","updateTime_date_str":"2022-11-19","createBy":"274332f8f1fe419096a2a5623dbfefb8","system":"shop","createTime":"2022-11-19 23:46:21","name":"角色2","updateTime_str":"2022-11-19 23:46:21","createTime_date_str":"2022-11-19"},{"code":"D1","parentPath":"0,271341a834844ab3b6860771fe9a786f,","delFlag":"0","updateBy":"274332f8f1fe419096a2a5623dbfefb8","sysAttachments":[],"id":"271341a834844ab3b6860771fe9a786f","shopId":"ef4ccd55cfec4d93a607c04cab023794","state":"1","updateTime":"2022-11-19 23:45:53","sort":999,"createTime_str":"2022-11-19 23:45:53","parentId":"0","updateTime_date_str":"2022-11-19","createBy":"274332f8f1fe419096a2a5623dbfefb8","system":"shop","createTime":"2022-11-19 23:45:53","name":"角色1","updateTime_str":"2022-11-19 23:45:53","createTime_date_str":"2022-11-19"}],"pageNum":1,"pageSize":15,"size":2,"startRow":0,"endRow":1,"pages":1,"prePage":0,"nextPage":0,"isFirstPage":true,"isLastPage":true,"hasPreviousPage":false,"hasNextPage":false,"navigatePages":8,"navigatepageNums":[1],"navigateFirstPage":1,"navigateLastPage":1,"firstPage":1,"lastPage":1};
				})
				.postJson('/demo/role/page', data);
		},

		getInfo (data){
			return http
				.mock(function () {
				    return {"resources": [{"id": "11"}],"code":"D2","parentPath":"0,ee5224cb6bd64be3a287b11cd70b2fe0,","delFlag":"0","updateBy":"274332f8f1fe419096a2a5623dbfefb8","sysAttachments":[],"id":"ee5224cb6bd64be3a287b11cd70b2fe0","shopId":"ef4ccd55cfec4d93a607c04cab023794","state":"1","updateTime":"2022-11-19 23:46:21","sort":999,"createTime_str":"2022-11-19 23:46:21","parentId":"0","updateTime_date_str":"2022-11-19","createBy":"274332f8f1fe419096a2a5623dbfefb8","system":"shop","createTime":"2022-11-19 23:46:21","name":"角色2","updateTime_str":"2022-11-19 23:46:21","createTime_date_str":"2022-11-19"}
				})
				.post('/demo/role/get', data);
		},

		saveInfo (data){
			return http
				.mock()
				.postJson('/demo/role/saveAndBinding', data);
		},

		delete (data){
			return http
				.mock()
				.postJson('/demo/role/delete', data);
		}
	}
}
